package com.nwpu.coursesupport.pagination;

public abstract class Dialect {

	/**
	 * Check whether the database support paging
	 * 
	 * @return
	 */
	public abstract boolean supportsLimit();

	/**
	 * Get records' count sql
	 * 
	 * @param sql
	 * @return
	 */
	public String getCountSql(String sql) {
		return "SELECT COUNT(1) FROM (" + sql + ") temp";
	}

	/**
	 * Get limit sql
	 * 
	 * @param sql
	 * @param offset
	 * @param limit
	 * @return
	 */
	public abstract String getLimitSql(String sql, int offset, int limit);
}
